const path = require('path');

function resolve(dir) {
	return path.join(__dirname, dir);
}

module.exports = {
	lintOnSave: 'error',
	devServer: {
		host: '0.0.0.0', // host
		port: '8888', // 端口
		open: false, // 自动打开浏览器
		proxy: {
			'/api': {
				target: 'https://contract.360mex.vip',
				ws: true,
				changeOrigin: true,
				pathRewrite: {
					'^/api': '',
				},
			},
		},
		overlay: {
			warning: true,
			errors: true,
		},

	},
	productionSourceMap: false,
	publicPath: '/',
	outputDir: 'dist',
	chainWebpack: (config) => {
		config.resolve.alias
			.set('@', resolve('src')); // alias
		config.output.filename('[name].[hash].js')
			.end(); // 打包文件带hash
		// config
		//   .plugin('webpack-bundle-analyzer')
		//   .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
	},
	configureWebpack: config => {
		if (process.env.NODE_ENV !== 'production') {
			config.devtool = 'source-map'
		}
		// plugins: [
		//     new webpack.ProvidePlugin({
		//         $:'jquery',
		//         jQuery:'jquery',
		//         'window.jQuery':'jquery'
		//     })
		// ]
	},
};
